Package com.fsf.news

Class GuiceExtension

java.lang.Object
com.fsf.news.GuiceExtension
All Implemented Interfaces:
org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.Extension

public class GuiceExtension extends Object implements org.junit.jupiter.api.extension.BeforeEachCallback
A JUnit extension that sets up Guice injection for tests that apply it.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final com.google.inject.Injector
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    beforeEach(org.junit.jupiter.api.extension.ExtensionContext context)
    Injects dependencies into the test instance before each test.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • injector

      private final com.google.inject.Injector injector
  • Constructor Details

    • GuiceExtension

      public GuiceExtension()
  • Method Details

    • beforeEach

      public void beforeEach(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception
      Injects dependencies into the test instance before each test.
      Specified by:
      beforeEach in interface org.junit.jupiter.api.extension.BeforeEachCallback
      Parameters:
      context - The extension context for the current test
      Throws:
      Exception - If an error occurs during injection